//
//  ManagerCollectionViewCellSecond.m
//  ZhuoxinAgriculture
//
//  Created by stone on 16/11/8.
//  Copyright © 2016年 KKING. All rights reserved.
//

#import "ManagerWebViewController.h"
#import "ManagerCollectionViewCellSecond.h"
#import "ManagerButton.h"
#import "Masonry.h"
#import "FalseImgViewController.h"
#import "HeadlineController.h"


@interface ManagerCollectionViewCellSecond()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *leftCenterConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *rightCenterConstraint;


@property (weak, nonatomic) IBOutlet ManagerButton *seedProgramButton;
@property (weak, nonatomic) IBOutlet ManagerButton *seedDemandButton;
@property (weak, nonatomic) IBOutlet ManagerButton *fertilizerDemandButton;
@property (weak, nonatomic) IBOutlet ManagerButton *pesticideDemandButton;
/** imageView */
@property (weak, nonatomic) UIImageView * backImageView;
@end
@implementation ManagerCollectionViewCellSecond
//- (instancetype)initWithCoder:(NSCoder *)coder
//{
//    self = [super initWithCoder:coder];
//    if (self) {
//
//
//        UIImageView * backImageView = ({
//            UIImageView * imageView = [[UIImageView alloc] init];
//            UIImage * image = [UIImage imageNamed:@"Rectangle_1"];
//            imageView.image = image;
//
//            [self.contentView insertSubview:imageView atIndex:0];
//
//            [imageView mas_makeConstraints:^(MASConstraintMaker * make) {
//                make.left.mas_equalTo(self.contentView.mas_left).offset(0);
//                make.right.mas_equalTo(self.contentView.mas_right).offset(0);
//                make.top.mas_equalTo(self.contentView.mas_top).offset(0);
//                make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(0);
//            }];
//
//            imageView;
//        });
//        self.backImageView = backImageView;
//    }
//    return self;
//}
- (void)awakeFromNib {
    [super awakeFromNib];
    
    CGFloat centervalue = 82.5 * 2;
    self.rightCenterConstraint.constant = (centervalue * 0.5) / 375 * [UIScreen mainScreen].bounds.size.width;
    self.leftCenterConstraint.constant = -(centervalue * 0.5) / 375 * [UIScreen mainScreen].bounds.size.width;
    
    // Initialization code
    self.seedProgramButton.nameLabel.text = @"种植计划";
    self.seedProgramButton.iconImageView.image = [UIImage imageNamed:@"种植计划"];
    
    self.seedDemandButton.nameLabel.text = @"种子用量";
    self.seedDemandButton.iconImageView.image = [UIImage imageNamed:@"种子用量"];
    
    self.fertilizerDemandButton.nameLabel.text = @"肥料用量";
    self.fertilizerDemandButton.iconImageView.image = [UIImage imageNamed:@"肥料用量"];
    
    self.pesticideDemandButton.nameLabel.text = @"农药用量";
    self.pesticideDemandButton.iconImageView.image = [UIImage imageNamed:@"农药用量"];
    
}
/*
 种子资金
 https://www.zhuoyinong.com:444/zhuoxin_web/seed_funds.html
 种子用量
 https://www.zhuoyinong.com:444/zhuoxin_web/seed_dosage.html
 肥料用量
 https://www.zhuoyinong.com:444/zhuoxin_web/fertilize_dosage.html
 肥料资金
 https://www.zhuoyinong.com:444/zhuoxin_web/fertilize_funds.html
 业务规模
 https://www.zhuoyinong.com:444/zhuoxin_web/business_scale.html
 业务增长规模
 https://www.zhuoyinong.com:444/zhuoxin_web/business_growth_scale.html
 土地规模
 https://www.zhuoyinong.com:444/zhuoxin_web/land_scale.html
 农户规模
 https://www.zhuoyinong.com:444/zhuoxin_web/smallholdes_scale.html
 种植计划
 https://www.zhuoyinong.com:444/zhuoxin_web/plant_plan.html
 
 */

/** 种植计划 */
- (IBAction)seedProgramButtonClick:(ManagerButton *)sender {
    //    [self pushViewControllerWithImageName:@"领导驾驶舱-种植计划"];
    //    NSLog(@"%@ | %s",self.class,__func__);
    [self pushViewControllerWithURLString:@"https://www.zhuoyinong.com:444/zhuoxin_web/plant_plan.html"];
}
/** 种子用量 */
- (IBAction)seedDemandButtonClick:(ManagerButton *)sender {
    //    [self pushViewControllerWithImageName:@"领导驾驶舱-种子用量"];
    [self pushViewControllerWithURLString:@"https://www.zhuoyinong.com:444/zhuoxin_web/seed_dosage.html"];
    
}

/** 肥料需求 */
- (IBAction)fertilizerDemandButtonClick:(ManagerButton *)sender {
    //    [self pushViewControllerWithImageName:@"领导驾驶舱-肥料用量"];
    [self pushViewControllerWithURLString:@"https://www.zhuoyinong.com:444/zhuoxin_web/fertilize_dosage.html"];
}
/** 农药需求 */
- (IBAction)pesticideDemandButtonClick:(ManagerButton *)sender {
    [self pushViewControllerWithImageName:@"领导驾驶舱-农药用量"];
//    [self pushViewControllerWithURLString:@""];
}



- (void)pushViewControllerWithURLString:(NSString *)urlString
{
    HeadlineController * vc = [HeadlineController new];
    vc.url = urlString;
    UIResponder * next = [self nextResponder];
    
    while (next != nil) {
        
        if ([next isKindOfClass:UINavigationController.class]) {
            
            [((UINavigationController *)next) pushViewController:vc animated:YES];
            break;
        }
        
        next = [next nextResponder];
    }
}


- (void)pushViewControllerWithImageName:(NSString *)imageName
{
    FalseImgViewController *fVc = [[FalseImgViewController alloc]init];
    fVc.imgName = imageName;
    [self.nav pushViewController:fVc animated:YES];
}

@end
